package d6_set;

import java.util.HashSet;
import java.util.Set;

public class SetDemo03 {
    public static void main(String[] args) {
        // 目标: 理解HashSet集合去重复(重点是如何对对象去重)
        Set<Student> sets = new HashSet<>();
        Student s1 = new Student("陈平安", '男', "宁姚");
        Student s2 = new Student("宁姚", '女', "陈平安");
        Student s3 = new Student("叶凡", '男', "姬紫月");
        Student s4 = new Student("姬紫月", '女', "叶凡");
        Student s5 = new Student("姬紫月", '女', "叶凡");

        System.out.println(s4.hashCode());
        System.out.println(s5.hashCode());

        sets.add(s1);
        sets.add(s2);
        sets.add(s3);
        sets.add(s4);
        sets.add(s5);
        System.out.println(sets);
        sets.forEach(System.out::println);

    }
}
